//
//  RanCollectionTestController.m
//  ThusMyStyle
//
//  Created by Ran on 15/11/10.
//  Copyright (c) 2015年 gintong. All rights reserved.
//

#import "RanCollectionTestController.h"
#import "RanCollectionViewCell.h"
#import "RanCollectionViewLayout.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <MWPhotoBrowser/MWPhotoBrowser.h>
#import <ELCImagePickerController/ELCImagePickerController.h>
#import <MobileCoreServices/UTCoreTypes.h>


@interface RanCollectionTestController ()<UICollectionViewDataSource, UICollectionViewDelegate>



@end

@interface RanCollectionTestController ()<UICollectionViewDataSource, UICollectionViewDelegate>

@property(nonatomic, weak)UICollectionView *collectionview;

@end

@implementation RanCollectionTestController

#pragma mark - LifeCycle
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] init];
    
    elcPicker.maximumImagesCount = 9; //Set the maximum number of images to select to 100
//    elcPicker.returnsOriginalImage = YES; //Only return the fullScreenImage, not the fullResolutionImage
//    elcPicker.returnsImage = YES; //Return UIimage if YES. If NO, only return asset location information
//    elcPicker.onOrder = YES; //For multiple image selection, display and return order of selected images
//    elcPicker.mediaTypes = @[(NSString *)kUTTypeImage, (NSString *)kUTTypeMovie]; //Supports image and movie types
//    
//    elcPicker.imagePickerDelegate = self;
    
    [self presentViewController:elcPicker animated:YES completion:nil];
}

- (void)setupUI
{
    self.view.backgroundColor = [UIColor blackColor];
    return;
//    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
//    layout.itemSize = CGSizeMake(40, 40);
//    layout.minimumInteritemSpacing = 10;
//    layout.minimumLineSpacing = 10;
//    layout.sectionInset = UIEdgeInsetsMake(30, 10, 10, 10);
    
    RanCollectionViewLayout *layout = [[RanCollectionViewLayout alloc] init];
    
    UICollectionView *collectionview = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
    collectionview.dataSource = self;
    collectionview.delegate = self;
    [self.view addSubview:collectionview];
    self.collectionview = collectionview;
    [collectionview registerClass:[RanCollectionViewCell class] forCellWithReuseIdentifier:@"c"];
    collectionview.allowsMultipleSelection = YES;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 20;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"c" forIndexPath:indexPath];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

}

- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
    return YES;
}

- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
    NSString *str = NSStringFromSelector(action);
    NSLog(@"%@", str);
}

- (void)cut: (id)sender
{
    NSLog(@"cut");
}

- (void)copy:(id)sender
{
    NSLog(@"copy");
}

- (void)paste:(id)sender
{
    NSLog(@"paste");
}

@end
